You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I found a bug which occurs when using the flags --intermediate, and not finding any solutions. objective(self) in src/minizinc/result.py picks out the last element in a list inside getattr-function. I think this causes a bug as when we have no solution, solve() in src/minizinc/instance.py returns an empty list which results in IndexError: list index out of range.
Here is the code in result.py, I think a simple if-statement is enough to fix it.
@propertydefobjective(self) ->Optional[Union[int, float]]:
"""Returns objective of the solution Returns the objective of the solution when possible. If no solutions have been found or the problem did not have an objective, then None is returned instead. Returns: Optional[Union[int, float]]: best objective found or None """ifself.solutionisnotNone:
ifisinstance(self.solution, list):
returngetattr(self.solution[-1], "objective", None) # <----- here is the bugelse:
returngetattr(self.solution, "objective", None)
else:
returnNone
Please let me know if I have just misunderstood something (and it is not an actual bug).
The text was updated successfully, but these errors were encountered:
I think I found a bug which occurs when using the flags
--intermediate
, and not finding any solutions.objective(self)
insrc/minizinc/result.py
picks out the last element in a list insidegetattr
-function. I think this causes a bug as when we have no solution,solve()
insrc/minizinc/instance.py
returns an empty list which results inIndexError: list index out of range
.Here is the code in
result.py
, I think a simple if-statement is enough to fix it.Please let me know if I have just misunderstood something (and it is not an actual bug).
The text was updated successfully, but these errors were encountered: